#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=110;
priority_queue<ll> q;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		ll t;
		cin>>t;
		q.push(t);
	}
	ll mmax=q.top(); q.pop();
	ll mmin=q.top(); q.pop();
	ll d=0;
	d=max(d,mmax-mmin);
	while(q.size())
	{
		ll a=q.top(); q.pop();
		d=max(d,mmax-a);
		mmax=a;
		swap(mmax,mmin);
	}
	d=max(d,mmax-mmin);
	cout<<d;

	return 0;
}

